import React, { Component } from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    Button,
    Image,
    View,
    TouchableOpacity
} from 'react-native';




export default class HomePage extends React.Component {
    //在这里定义每个页面的导航属性
//    static navigationOptions = {
//        title: 'Home',
//        headerBackTitle:'返回哈哈',//设置返回此页面的返回按钮文案，有长度限制
//    }

  renderCenterBtn(index, value) {
    // key 区分唯一
      return (
            <Button
                key={value.key}
                title={value.title}
                onPress={() => {
                    this.props.navigation.navigate(value.key, {name: '动态的'});
                }}
            />
        )
    }
    render() {
//        const {navigation} = this.props;
        const obj=[{title:"Go To Page1",key:'Home'},
                    {title:"Go To Page2",key:'Details'},
                     {title:"Go To Page3",key:'Page3'}]
    /* 动态生成按钮 */
        return (
            <View>
            <Text >欢迎来到HomePage</Text>

            {obj.map((value, index) => this.renderCenterBtn(index, value))}

            </View>
        )
    }
}

/*            <Button
//                title="Go To Page1"
//                onPress={() => {
//                    this.props.navigation.navigate('Home', {name: '动态的'});
//                }}
//            />
//            <Button
//                title="Go To Page2"
//                onPress={() => {
//                    this.props.navigation.navigate('Details');
//                }}
//            />
//            <Button
//                title="Go To Page3"
//                onPress={() => {
//                    this.props.navigation.navigate('Page3',{ name: 'Devio',title:"this is test title" });
//                }}
          /> */